package com.broada.apm.dao.impl;

import java.util.List;

import com.broada.apm.dao.DimensionDao;
import com.broada.apm.model.Dimension.Area;
import com.broada.apm.model.Dimension.Browser;
import com.broada.apm.model.Dimension.Device;
import com.broada.apm.model.Dimension.Error;
import com.broada.apm.model.Dimension.OS;

public class MysqlDimensionDao extends MysqlAbstractDao implements DimensionDao {

	public static final String DIMENSION_NAMESPACE = "com.broada.apm.dao.DimensionDao.";
	
	@Override
	public void addError(Error error) {
		getSqlSession().insert(DIMENSION_NAMESPACE + "addError", error);
	}

	@Override
	public void updateError(Error error) {
		getSqlSession().update(DIMENSION_NAMESPACE + "updateError", error);
	}

	@Override
	public List<Error> getErrorByL7Protocol(int protocol) {
		return getSqlSession().selectList(DIMENSION_NAMESPACE + "getErrorByL7Protocol", protocol);
	}

	@Override
	public void deleteError(Error error) {
		getSqlSession().delete(DIMENSION_NAMESPACE + "deleteError", error);
	}

	@Override
	public List<Browser> getAllBrowsers() {
		return getSqlSession().selectList(DIMENSION_NAMESPACE + "getAllBrowsers");
	}

	@Override
	public List<Device> getAllDevices() {
		return getSqlSession().selectList(DIMENSION_NAMESPACE + "getAllDevices");
	}

	@Override
	public List<OS> getAllOSs() {
		return getSqlSession().selectList(DIMENSION_NAMESPACE + "getAllOSs");
	}

	@Override
	public List<Area> getAllAreas() {
		return getSqlSession().selectList(DIMENSION_NAMESPACE + "getAllAreas");
	}

	@Override
	public List<Area> getRootArea() {
		return getSqlSession().selectList(DIMENSION_NAMESPACE + "getRootArea");
	}

	@Override
	public List<Area> getProvinceArea(String root) {
		return getSqlSession().selectList(DIMENSION_NAMESPACE + "getProvinceArea", root);
	}

	@Override
	public List<Area> getCityArea(String province) {
		return getSqlSession().selectList(DIMENSION_NAMESPACE + "getCityArea", province);
	}

	@Override
	public List<Area> getDistrictArea(String district) {
		return getSqlSession().selectList(DIMENSION_NAMESPACE + "getDistrictArea", district);
	}

	@Override
	public Error getErrorById(String id) {
		return getSqlSession().selectOne(DIMENSION_NAMESPACE + "getErrorById", id);
	}

}
